<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<!-- 说明 字符串：Material，作为替换字符串 -->
<div class="easyui-layout" style="width:100%;height:100%;">
    <!-- 主表  -->
    <table id="cztj_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
           data-options="rownumbers:true, pagination:false,singleSelect:true,url:'/report-czjl/0/20',
					  method:'get',
					  fitColumns : true,
					  toolbar:'#tb',
					  loadMsg : '数据加载中',
					  showFooter: true" >
        <thead>
        <th data-options="field:'material',width:200,align:'center' ">物资</th>
        <th data-options="field:'supplier',width:200,align:'center' ">发货单位</th>
        <#--<th data-options="field:'gross',width:200,align:'center' ">总毛重</th>-->
        <#--<th data-options="field:'tare',width:200,align:'center' ">总皮重</th>-->
        <th data-options="field:'suttle',width:200,align:'center' ">总净重</th>
        <#--<th data-options="field:'ts',width:200,align:'center' ">总实重</th>-->
        <th data-options="field:'count',width:200,align:'center' ">车次</th>
        </thead>
    </table>
</div>

<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
    <div>
        <input class="easyui-datetimebox" data-options="formatter:dateformatter,parser:dateparser,showSeconds:true" id="from" style="width:200px">
        <input class="easyui-datetimebox" data-options="formatter:dateformatter,parser:dateparser,showSeconds:true" id="to" style="width:200px">
        <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
    </div>
    <div style="margin:5px 0;"></div>
    <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-download'"  id="export">下载</a>
</div>

<!-- 按钮操作 -->
<script type="text/javascript">

    function dateformatter(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        var hor = date.getHours();
        var min = date.getMinutes();
        var sec = date.getSeconds();
        var time = y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d)+' '+(hor<10?('0'+hor):hor)+':'+(min<10?('0'+min):min)+':'+(sec<10?('0'+sec):sec);
        console.info(time)
        return time;
    }
    function dateparser(s){
        // console.info(s)
        if (!s) return new Date();
        var hfm = (s.split(' '))[1];
        var ss = (s.split('-'));
        var y = parseInt(ss[0],10);
        var m = parseInt(ss[1],10);
        var d = parseInt(ss[2],10);
        var hour = parseInt(hfm.split(':')[0]);
        var min = parseInt(hfm.split(':')[1]);
        var sec = parseInt(hfm.split(':')[2]);
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)&&!isNaN(hour) && !isNaN(min) && !isNaN(sec)){
            return new Date(y,m-1,d,hour,min,sec);
        } else {
            return new Date();
        }
    }
    $('#export').click(function(){
        var from = $('#from').val();
        var to = $('#to').val();
        window.location = '/report-czjl-download?from='+from+"&to="+to;

    });
    $('#searchByParameter').click(function () {
        var from = $('#from').val();
        var to = $('#to').val();
        var handler = '/report-czjl/0/20?from='+from+"&to="+to;
        $('#cztj_table').datagrid('options').url = handler;
        $('#cztj_table').datagrid('reload');

    })
</script>

